Materials/ Visual Shading Language/ Illumination Examples

Illumination Examples

Paper

It is possible to define custom surface illumination effects by using a 'Surface illumination' shader. The following material; paper, has the property that lighting (including shadows) is visible through the paper (to a certain extent).

The illumination shader computes the product of the dot products <ray*normal> and <lightray*normal>. This product is negative only when the surface is viewed from the opposite side of lighting. The 'If' object notices this and computes illumination in those cases where default shading would leave surface without illumination. The alternate shading actions are very simple: the lighting intensity is modified by the lighting angle and then reduced by 50 %, because all the light cannot penetrate the paper.

Example file: tutorprojects/material/vsl/paper
 

Fur

This example material simulates a surface covered by dense, short fur that shines in light.

 

  • The 'Surface properties' shader includes only one object, which adds a low amount of diffuse color by scaling down the 'furcolor' value defined in the 'Material Initialization' shader.
  • The actual trick is made in the 'Surface illumination' shader: illumination is defined so that it reaches the maximum value when the small hairs are viewed from the side. This behavior is quite different from the usual diffuse shading.
  • The 'If' object tests, that light does not get through the surface.
  • The two curve objects define the amount of illumination; by modifying these curves, surface appearance can be adjusted.

Example file: tutorprojects/material/vsl/shinyfur
Example file: tutorprojects/material/vsl/silk
 
 

Matte shadows

In the 'Surface illumination' shader, both the original light properties of a light source and the amount of light reaching the examined surface point are available.  It is possible to compare these two channels for creating advanced 'matte' effects. In the example below, a photographed backdrop is not illuminated by the light sources (the photograph already includes illumination), but 3D objects still cast shadows on it.

1. Create the following VSL material:

 

2. Create a camera object using the camera tool.

3. Create a backdrop object using the backdrop tool. Use the material defined above.

4. Put some objects in front of the backdrop, and some light sources behind objects, so that objects cast shadows to the backdrop.

5. Take the camera view (View's popup Camera/Object View) and render.

 
Notes:

  • In the 'Surface properties' shader, the color of the backdrop is assigned directly to the illumination channel. The result will show the color in its unmodified state. Diffuse color is set to black to eliminate other shading effects.
  • The 'Surface illumination' shader first computes 'the amount of shadow'. Negative values are truncated to zero, and the 'Surface:Illumination' channel is scaled by the resulting factor.
  • This example shows a situation where the backdrop image is in a digital form. We could also store the amount of shadow into the alpha channel. This would allow generation of shadows later to any background video sequence. It is also possible to map reflecting color to the areas where the backdrop image is supposed to reflect the environment and so on - the possibilities are endless.

Example file: tutorprojects/material/vsl/matteshadows
Example file: tutorprojects/material/vsl/alphashadows
   

Slide projector

1. Create a light source.

2. Then apply the following material to it (for example using a parallel mapping):

Notes:

The mapped material defines light properties in the examined illuminated surface point, not on the surface of the mapping object. This means that the parallel projection used in the example above works best with a distant light source, because both 'project' their influence in a similar way. A pyramid mapping matches with a point light source.

Example file: tutorprojects/material/vsl/slideprojector
 
 

Custom light falloff rate

This example is recommended for those users who are familiar with polar space coordinates.

1. Create a point light source.

2. Then apply the following material to it using a spherical mapping. The origin point of the mapping should match the position of the light source.

 

Notes:

  • The three curves of the curve shader control the light falloff with respect to polar coordinates. In other words, it is possible to 'draw' the shape of the light beam created by the light source:
  • The red curve controls the first polar parameter, 'heading'. This may be constant in which case the light distribution is symmetric. By making peaks to it, light source may send more light up, to the left, etc.
  • The green curve controls the 'pitching' parameter. Zero pitching corresponds the direction of the spot axis, a pitching of 0.5 is 180 degrees from the axis. Curve values greater than 0.5 control directions behind the light source. For example: if the green curve has a high value in the beginning, the spotlight will have high intensity in the middle. By changing this parameter, it is possible to make the light source cast a light ring, for example.
  • The blue curve is perhaps the most useful one: it defines the falloff by distance. Usually this curve decreases down to zero. The size of the sphere mapping defines the corresponding area in space. By resizing it, it is possible to adjust the area of influence of the light source.
  • A more intuitive way to control the shape of a light beam is based on a slide projector idea. Draw two gray scale images, which show the shape and falloff of the light beam. Then map them to the light source from the side and from the top using a parallel mapping.

Example file: tutorprojects/material/vsl/curvelight
 
 

Gamma ray light sources

This example shows how to create a light source that casts special kind of light that illuminates only certain kind of objects.

1. Create a new channel of type 'Float' using the 'New' popup menu of the 'Channels' tab of the select window. Rename it as 'gamma'.

2. Create a light source and map the following material to it:

 
'If' object tests if the gamma channel value is inside 0.01 and 1
 
3. Create an object and map the following material to it (any mapping type is suitable):

 
The 'Constant' object assigns a value between 0.01 and 1 to the gamma channel
 
Only objects with 'gamma material' become illuminated by gamma light.

Example file: tutorprojects/material/vsl/gammalight
 
 

Reflective in light

Light can define surface properties. For example, a light source can act as an X-ray radiator, which makes objects transparent. Or, like the example below shows, lighting can control the reflectivity of a surface.

Notes:

  • 'Lightbuffer' is a user defined color channel. The amount of light arriving from light sources is summed into it.
  • In the 'Secondary ray' shader, the illumination of the traced reflection ray is scaled by the total sum of light.

Example file: tutorprojects/material/vsl/lightmakesreflective